import request  from '@/api/request'

/**
 * @description -封装User类型的接口方法
 */
export class UserService {       // 模块一
    /**
     * @description 用户登录
     * @param {string} username - 用户名
     * @return {HttpResponse} result
     */
    static async login(data) {   // 接口一
        return request({
            url : '/auth/oauth2/token',
            method : 'post',
            data : data,
            headers :{
                'Content-Type' : 'application/x-www-form-urlencoded',
                'Authorization' : 'Basic ' + window.btoa('acc:acc')
            }
        })
    }
    static async getUserMenu(params){
        return request({
            url : '/admin/menu',
            method : 'get',
            params : params,
            headers : {
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
    static async getTree(params){
        return request({
            url : '/admin/dept/tree',
            method : 'get',
            params : params,
            headers :{
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
    static async  getUserList(params){
         return request({
            url : '/admin/user/page',
            method : 'get',
            params : params,
            headers :{
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
    static async addUser(data){
        return request({
            url : '/admin/user',
            method : 'post',
            data : data,
        })
    }

    static async getRoleList(){
        return request({
            url : '/admin/role/list',
            method : 'get',
        })
    }
    static async getDeptList(){
        return request({
            url : '/admin/dept/list',
            method : 'get',
        })
    }
    // 删除用户
    static async delUser(data){
        return request({
            url : '/admin/user',
            method : 'delete',
            data : data
        })
    }
    static async lockUser(params){
        return request({
            url : '/admin/user/lock/' + params,
            method : 'put',
            headers :{
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
    static async updateUserInfo(data){
        return request({
            url : '/admin/user',
            method : 'put',
            data : data,
        })
    }
}
export class roleClass {     // 模块二
    /**
     * @description 获取地列表
     * @return {HttpResponse} result. /role/page
     */
    static async getRoleList(params) {
         return request({
            url : '/admin/role/page',
            method : 'get',
            params : params,
            headers :{
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
    static async delRole(data){
        return request({
            url : '/admin/role',
            method : 'delete',
            data : data
        })
    }

    static async addRole(data){
        return request({
            url : '/admin/role',
            method : 'post',
            data : data,
        })
    }
    static async updateRole(data){
        return request({
            url : '/admin/role',
            method : 'put',
            data : data,
        })
    }
    static async updateRoleMenu(data){
         return request({
            url : '/admin/role/menu',
            method : 'put',
            data : data,
        })
    }
    static async getCurrentAuth(data){
        return request({
            url : '/admin/menu/tree/' + data,
            method : 'get',
            headers : {
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
}
export class menuClass{
    static async getMenuList() {
         return request({
            url : '/admin/menu/tree',
            method : 'get',
            headers : {
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
    static async addMenu(data){
         return request({
            url : '/admin/menu',
            method : 'post',
            data : data,
        })
    }
    static async updateMenu(data){
         return request({
            url : '/admin/menu',
            method : 'put',
            data : data,
        })
    }
    static async delMenu(params){
        return request({
            url : '/admin/menu/' + params,
            method : 'delete',
            headers : {
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
}
export class deptClass{
    static async getDeptList() {
         return request({
            url : '/admin/dept/tree',
            method : 'get',
            headers : {
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
    static async getSelectDept(){
        return request({
            url : '/admin/dept/list',
            method : 'get',
            headers : {
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
     static async addDept(data){
         return request({
            url : '/admin/dept',
            method : 'post',
            data : data,
        })
    }
     static async updateDept(data){
         return request({
            url : '/admin/dept',
            method : 'put',
            data : data,
        })
    }

    static async delDept(params){
        return request({
            url : '/admin/dept/' + params,
            method : 'delete',
            headers : {
                'Content-Type' : 'application/x-www-form-urlencoded',
            }
        })
    }
}